import pymysql
from sshtunnel import SSHTunnelForwarder
with SSHTunnelForwarder(
        ('114.115.203.156','22'),
        ssh_username='root',
        ssh_pkey="/Users/chengyanan/.ssh/id_rsa",
        ssh_private_key_password='91799cccC.',
        remote_bind_address=('api-main-write.rds.hw.kuai8.mobi','3306')) as server:
    conn = pymysql.connect(host='127.0.0.1',
                           port=server.local_bind_port,
                           user='write',
                           passwd='anbs23T4main',
                           db='main'
)
    cursor = conn.cursor()
    cursor.execute("SELECT VERSION()；")
